package com.share.device.controller;

import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.common.core.web.page.TableDataInfo;
import com.share.device.domain.CabinetType;
import com.share.device.service.ICabinetTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "柜机类型接口管理")
@RestController
@RequestMapping("/cabinetType")
public class CabinetTypeController extends BaseController {
    @Autowired
    private ICabinetTypeService cabinetTypeService;

    @Operation(summary = "查询柜机类型列表")
    @GetMapping("/list")
    public TableDataInfo list(CabinetType cabinetType) {
        startPage();
        List<CabinetType> list = cabinetTypeService.selectCabinetTypeList(cabinetType);
        return getDataTable(list);
    }

    @Operation(summary = "根据id查询")
    @GetMapping("{id}")
    public AjaxResult getById(@PathVariable Long id) {
        return success(cabinetTypeService.getById(id));
    }

    @Operation(summary = "新增")
    @PostMapping
    public AjaxResult save(@RequestBody CabinetType cabinetType) {
        return toAjax(cabinetTypeService.save(cabinetType));
    }

    @Operation(summary = "修改")
    @PutMapping
    public AjaxResult updateById(@RequestBody CabinetType cabinetType) {
        return toAjax(cabinetTypeService.updateById(cabinetType));
    }

    @Operation(summary = "删除")
    @DeleteMapping
    public AjaxResult deleteByIds(@RequestBody List<Long> ids ){
        return toAjax(cabinetTypeService.removeBatchByIds(ids));
    }

    @Operation(summary = "获取全部")
    @GetMapping("/getCabinetTypeList")
    public AjaxResult getCabinetTypeList(){
        List<CabinetType> list = cabinetTypeService.list();
        return success(list);
    }
}
